package cn.sofwin.day0205;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;

public class IoTest {
    public static void main(String[] args) throws IOException {
        String filePath = "D:/dev/java/works/java2021/src/cn/sofwin/day0205/test.txt";
        File file = new File(filePath);

        // 测试读取文件内容
        String content = FileUtils.readFileToString(file, "UTF-8");
        System.out.println(content);

        // 测试写文件
        content = "这是新内容\n";
        FileUtils.writeStringToFile(file, content, "UTF-8", true);

        // 复制文件
        File newFile = new File("D:/dev/java/works/java2021/src/cn/sofwin/day0205/test111.txt");
        FileUtils.copyFile(file, newFile);
    }
}
